/*--------------------------------------------------------------
 * File: demo47.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 将一个数组拆分成一个奇数数组和一个偶数数组
 * Version 0.1
 * Date 2022-07-18 
 * 
 * @copyright Copyright (c) 2022
 * 
----------------------------------------------------------------*/

#include <stdio.h>

int main(int argc, char const *argv[])
{
    int array[] = {0,1,2,3,4,5,6,7,8,9};
    int even[1], odd[10];
    int loop, e, d;
    e = d = 0;

    for(loop = 0; loop < 10; loop++)
    {
        if(array[loop]%2 == 0)
        {
            even[e] = array[loop];
            e++;
        }
        else
        {
            odd[d] = array[loop];
            d++;
        }
    }

    printf("原始数据组：");
    for(loop=0; loop<10; loop++)
        printf("%d ", array[loop]);
    printf("\n");
    
    printf("奇数组：");
    for(loop=0; loop<d; loop++)
        printf("%d ", odd[loop]);
    printf("\n");

        printf("偶数组：");
    for(loop=0; loop<e; loop++)
        printf("%d ", even[loop]);
    printf("\n");
    return 0;
}

